Introduction to Cloud Run
Serverless container workloads.
We'll cover the following
In the last lesson, we had a complete review of GKE. But, if you are a developer and don’t want to get your hands dirty with complex cluster management for your containerized workloads, then Cloud Run is for you.
Introduction#
Cloud Run allows us to run stateless containers in a serverless manner. Cloud Run supports event-based invocation of containers. Also, the service deployed to cloud run can also be accessed in other cloud platforms. We have 2 options to run a containerized workload in Cloud Run.
-
Application container running on a cluster totally managed by Google Cloud.
-
Application container running on a cluster created by us.
Cloud Run is backed by Knative. Knative is an extension of the Kubernetes and because of Knative, Cloud Run can start containers based on an event. HTTP trigger is default and can not be removed from Cloud Run. We can add different event-based triggers along with HTTP.
Usecases#
When to use Cloud Run? Well, you can use Cloud Run for every workload which has stateless containers and also when you need something which can scale down to 0 when there is no traffic. On-demand computing is also the best use case for Cloud Run.
Some example use-cases:
- Web services REST APIs backend
- Lightweight data transformation
- Business workflow with webhooks
You can look at these use cases in detail here.
Whenever you need to deploy the containers on an environment where you can scale down to 0 or need event-based triggers for your containerized workload, Cloud Run is the best choice.
Demo#
-
Open Main menu > Cloud Run
-
Click on the “Create Service” button. Required APIs will be enabled automatically after you click the button.
- In the form, assign a name to the service. Also, you can select the region where the containers will be deployed. Default will also work for now.
- Click on “SELECT” to choose the container image URL. You can provide any custom image from Google Container Registry. For the demo, choose “Demo Containers” and select the hello image. Leave the advanced settings for now. Those are container-specific. Click the next button.
-
In the next section, you can apply different filters on incoming traffic. Also, allow the unauthenticated invocations so that you can access the deployed code using the internet without any token or added security.
-
Add Eventarc Trigger: Cloud run is an event-based service. You can choose different event triggers to start cloud run instances. For now, we will not add any triggers.
-
Click the Create button.
Once the service is created, you will get a URL like https://cloud-run-demo-oxapdmvb6a-uc.a.run.app this one. This is a custom URL and you can map this URL to your domain very easily.
To use your own domain, go to the Cloud Run home page and click on “Manage Custom Domain” (Next to the “Create Service” button) and follow the steps.
Click on the URL for the service you have created. You will see a success message for the hello image you just deployed using Cloud Run.
If you have your application packaged in an image you can deploy it within a minute using the same steps.
Cloud Run has a lot more to offer like Anthos (Which is a new way of multicolored deployment) deployment, Continuous deployment using a CICD pipeline via Cloud Build, and canary testing feature. But for this exam, you just need to know when and how to use Cloud Run.
As a next step, we will review another managed service App Engine. App Engine was the oldest service of Google Cloud. So, definitely, there are architectural differences that you will come to know while learning app engine.
Google Kubernetes Engine
Creating Google App Engine